<template>
  <div class="aaa">
    <el-form ref="form" :model="form" label-width="100px" :inline="true">
      <el-form-item label="日期范围">
        <el-col :span="6">
          <el-date-picker
            type="date"
            placeholder="选择日期范围"
            v-model="form.date1"
            style="width: 100%"
          ></el-date-picker>
        </el-col>

        <el-select v-model="fomrinfrom" style="width:120px" :span="6">
          <el-option label="学员名称" value="1"></el-option>
          <el-option label="手机号码" value="0"></el-option>
        </el-select>
        <el-form-item>
          <el-input v-model.trim="ssss" placeholder="请输入关键字"></el-input>
        </el-form-item>

        <el-form-item>
          <el-button @click="onSubmit" size="medium">搜索</el-button>
          <el-button @click="resplt" size="medium">重置</el-button>
        </el-form-item>
      </el-form-item>
    </el-form>
    <el-button type="primary" size="small">批量导出</el-button>

    <el-table :data="reslist" border style="width: 100%">
      <el-table-column prop="real_name" label="讲师名称" width="180">
      </el-table-column>
      <el-table-column prop="mobile" label="手机号码" width="180" height="30px">
      </el-table-column>
      <el-table-column prop="course_num" label="所授课程"> </el-table-column>
      <el-table-column prop="chapter_num" label="总课时" width="180">
      </el-table-column>
      <el-table-column fixed="right" label="操作" width="100">
        <template>
          <el-button @click="dialogTableVisible = true" type="text" size="small"
            >授课记录</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <el-dialog title="授课记录" :visible.sync="dialogTableVisible">
      <el-table :data="gridData" border="">
        <el-table-column
          property="date"
          label="课程名称"
          width="100"
        ></el-table-column>
        <el-table-column
          property="name"
          label="课程类型"
          width="100"
        ></el-table-column>
        <el-table-column
          property="date"
          label="总课时"
          width="100"
        ></el-table-column>
        <el-table-column
          property="name"
          label="已完成课时"
          width="100"
        ></el-table-column>
        <el-table-column
          property="date"
          label="未完成课时"
          width="100"
        ></el-table-column>
        <el-table-column
          property="name"
          label="总授课时常"
          width="100"
        ></el-table-column>
      </el-table>
    </el-dialog>

    <div class="block">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="change"
        :current-page="currentpage"
        :page-sizes="[2, 3, 4, 5]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="lists.length"
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
import { getteach } from '../../../api'
export default {
  data() {
    return {
      fomrinfrom: '1',
      form: {
        data1: ''
      },
      ssss: '',
      gridData: [],
      lists: [],
      copylist: [],
      pageSize: 5,
      currentpage: 1,
      dialogTableVisible: false
    }
  },
  computed: {
    reslist() {
      return this.lists.slice(
        this.pageSize * (this.currentpage - 1),
        this.pageSize * this.currentpage
      )
    }
  },
  methods: {
    resplt() {
      this.lists = this.copylist
    },
    onSubmit() {
      if (this.fomrinfrom == 1) {
        this.lists = this.copylist.filter(item => {
          return item.real_name.includes(this.ssss)
        })
      } else if (this.fomrinfrom == 0) {
        this.lists = this.copylist.filter(item => {
          return item.mobile.includes(this.ssss)
        })
      }
    },
    change(val) {
      this.currentpage = val
    },
    handleSizeChange(val) {
      this.pageSize = val
    }
  },
  mounted() {
    getteach().then(res => {
      console.log(res)
      this.lists = res.data.list
      this.copylist = res.data.list
    })
  }
}
</script>

<style lang="scss">
.block {
  margin-left: 550px;
}
.el-dropdown {
  background-color: #fff;
  background-image: none;
  border-radius: 4px;
  border: 1px solid #dcdfe6;
  box-sizing: border-box;
  color: #606266;
  display: inline-block;
  font-size: inherit;
  height: 40px;
  line-height: 40px;
  outline: 0;
  padding: 0 15px;
  transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
  margin-left: 25px;
  width: 112px;
}
.el-dropdown-link {
  cursor: pointer;
  color: #409eff;
}
.el-icon-arrow-down {
  font-size: 12px;
}
</style>
